package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	r := gin.Default()
	r.POST("/from", func(context *gin.Context) {
		// 表单里的默认值
		type1 := context.DefaultPostForm("type", "alert")
		// 接收其他的
		username := context.PostForm("username")
		password := context.PostForm("password")
		// 多选框
		hobbys := context.PostFormArray("hobby")
		context.String(http.StatusOK,
			fmt.Sprintf("type is %s, username: %s, password: %s, hobby: %s", type1, username, password, hobbys))
	})
	r.Run(":8000")

}
